import QtQuick 2.11
import QtQuick.Window 2.2
import Qt.labs.platform 1.0
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.3

Page{
    id:pageDatabaseConfig
    Column{
        anchors.fill: parent
        GroupBox{
            id:paneDatabaseConfig
            contentWidth: parent.width
            contentHeight: parent.height/2
            title: qsTr("DatabaseConfigView/revise")
            label: Label {
                x: parent.leftPadding
                width: parent.availableWidth
                height: 20
                font.pixelSize: 16
                font.bold: true
                text: parent.title
                color: "#000000"
                background: Rectangle{
                    anchors.fill: parent
                }
                elide: Text.ElideRight
            }
            Column{
                anchors.fill: parent
            Grid{
                width: parent.width
                rows:4;
                columns: 5;
                spacing: 10;
                bottomPadding: 20
                Button{
                    id:buttonChooseConfigFile
                    text: qsTr("Choose Config File");
                    width: 200
                    height: 30
                    onClicked: {
                        fileDialog.mission="loadConfig";
                        fileDialog.open();

                    }
                }
                Repeater{
                    model: 4
                    Label{
                        width: 100
                        height: 30
                        text:""
                    }
                }

                Repeater{
                    model: ["role","title","typeStore","default"]
                    TextField{
                        width: 200
                        height: 30
                        font.family: "微软雅黑"
                        placeholderText: modelData
                        horizontalAlignment: Text.AlignRight
                        verticalAlignment: Text.AlignBottom
                        font.pixelSize: 16
                        selectByMouse: true;
                        background: Rectangle{
                            anchors.fill:parent
                            border.color: "grey"
                        }
                    }
                }


                Button{
                    id:addConfig
                    text: qsTr("Add Field")
                    width: 200
                    height: 30
                }
                Repeater{
                    id:repeaterDeleteConfig
                    model: ["role","title","typeStore","default"]
                    TextField{
                        width: 200
                        height: 30
                        font.family: "微软雅黑"
                        placeholderText: modelData
                        horizontalAlignment: Text.AlignRight
                        verticalAlignment: Text.AlignBottom
                        font.pixelSize: 16
                        selectByMouse: true;
                        background: Rectangle{
                            anchors.fill:parent
                            border.color: "grey"
                        }
                    }
                }
                Button{
                    id:buttonDeleteConfig
                    text:qsTr("Delete Config");
                    width: 200
                    height: 30

                }
                Button{
                    id:buttonUpdateConfig
                    text:qsTr("Update Config");
                    width: 200
                    height: 30
                }
            }
            CustomedTableview{
                id:tableDatabaseConfig
                width: parent.width;
                height: 400;
                highlightOnFocus: true
                onSelectionChanged: {

                }
            }
            }
            background: Rectangle{
                anchors.fill: parent
//                border.color: "black"

            }
        }
        GroupBox{
            id:paneDatabaseReadTest
            contentWidth: parent.width
            title: qsTr("DatabaseTestRecord")

            label: Label {
                x: parent.leftPadding
                width: parent.availableWidth
                height: 20
                font.pixelSize: 16
                font.bold: true
                text: parent.title
                color: "#000000"
                background: Rectangle{
                    anchors.fill: parent
                }
                elide: Text.ElideRight
            }
            Column{
                anchors.fill: parent

                Grid{
                    width: parent.width
                    rows:3;
                    columns: 3;
                    spacing: 10;
                    bottomPadding: 20
                    Button{
                        id:buttonChooseTestDatabaseFile
                        text: qsTr("Choose Database File");
                        width: 200
                        height: 30
                        onClicked: {
                            fileDialog.mission="";
                            //MainController.loadConfig();
                        }

                    }
                }
                CustomedTableview{
                    id:tableTestDatabaseRecord
                    width: parent.width;
                    height: 200;
                }
            }


            background: Rectangle{
                anchors.fill: parent
                border.color: "#00070606"

            }
        }

    }
    Component.onCompleted: {
        tableDatabaseConfig.initColumns([{"title":"col0","role":"0"},{"title":"col0","role":"0"},{"title":"col1","role":"1"},{"title":"col2","role":"2"}]);
        tableTestDatabaseRecord.initColumns([{"title":"col0","role":"0"},{"title":"col0","role":"0"},{"title":"col1","role":"1"},{"title":"col2","role":"2"}])
    }
}
